package vn.edu.saigontech.ncms.web.offering;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import vn.edu.saigontech.ncms.model.info.Offering;
import vn.edu.saigontech.ncms.service.OfferingService;
import vn.edu.saigontech.ncms.util.Checker;
import vn.edu.saigontech.ncms.web.BaseAction;

@SuppressWarnings("serial")
public class PrintingAction extends BaseAction {
	
	private Long id;
	private Long[] ids;
	private Date fromDate;
	private Date toDate;
	
	public String findClasses() {
		List<Offering> offerings = new ArrayList<Offering>();
		if(!Checker.isNull(this.ids)) {
			for (Long each : this.ids) {
				Offering offering = OfferingService.INSTANCE.findById(each);
				offerings.add(offering);
			}
		}
		REQUEST().setAttribute("offerings", offerings);
		REQUEST().setAttribute("fromDate", fromDate);
		REQUEST().setAttribute("toDate", toDate);
		return SUCCESS;
	}
	
	public String findSortedByFirstNameClasses() {
		List<Offering> offerings = new ArrayList<Offering>();
		if(!Checker.isNull(this.ids)) {
			for (Long each : this.ids) {
				Offering offering = OfferingService.INSTANCE.findById(each);
				offerings.add(offering);
			}
		}
		REQUEST().setAttribute("offerings", offerings);
		REQUEST().setAttribute("fromDate", fromDate);
		REQUEST().setAttribute("toDate", toDate);
		return SUCCESS;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long[] getIds() {
		return ids;
	}

	public void setIds(Long[] ids) {
		this.ids = ids;
	}
	
	public Date getFromDate() {
		return fromDate;
	}

	public void setFromDate(Date fromDate) {
		this.fromDate = fromDate;
	}

	public Date getToDate() {
		return toDate;
	}

	public void setToDate(Date toDate) {
		this.toDate = toDate;
	}
}